﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Interactivity;
using System.Windows.Controls;
using System.Windows.Media;

namespace ZhiHeng.OneCard.WpfClient.Common
{
 public class DataContextProxy:TriggerAction<DependencyObject>
  {
      protected override void Invoke(object parameter)
      {
          var parent = this.AssociatedObject as DependencyObject;
          var fe = this.AssociatedObject as FrameworkElement;
          while (parent != null)
          {
              if (parent.GetType() == typeof(DataGrid))
              {
                  var context = parent as DataGrid;
                  fe.DataContext = context.DataContext;
                  break;
              }
              parent = VisualTreeHelper.GetParent(parent) as DependencyObject;
          }
 
      }
  }
}
